package com.jalarbee.web.jsf.filter;

import java.util.Locale;
import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author devel
 */
public class Utf8CharacterEncodingFilter extends ViewHandlerWrapper {

    private ViewHandler viewHandler = null;
    private static final Logger logger = LoggerFactory.getLogger(Utf8CharacterEncodingFilter.class);

    public Utf8CharacterEncodingFilter(ViewHandler viewHandler) {
        logger.info("Instatiating my custom view handler");
        this.viewHandler = viewHandler;
    }

    @Override
    public ViewHandler getWrapped() {
        return viewHandler;
    }

    @Override
    public String calculateCharacterEncoding(FacesContext context) {
        logger.info("setting character encoding to utf-8");
        return "UTF-8";
    }

    @Override
    public Locale calculateLocale(FacesContext context) {
        logger.info("setting locale to Locale.US");
        return Locale.US;
    }
}
